package edu.xidian.sselab.cloudcourse.controller;

import edu.xidian.sselab.cloudcourse.domain.test5_entity;
import edu.xidian.sselab.cloudcourse.repository.test5_Repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.List;

@Controller
public class test5_controller {
    @Autowired
    private test5_Repository test5_repository;

    @RequestMapping("/test5")
    public String test5_try(Model model) {
        model.addAttribute("title", "轿车 SUV MPV总销量占比");
        return "test5";
    }

    @RequestMapping("/test21")
    public @ResponseBody
    List test5_try2() throws IOException {

        List<test5_entity> recordList = test5_repository.find();

        System.out.println("以下是SUV、MPV、紧凑型轿车三种车型的总销售量：");
        for(test5_entity t:recordList){
            System.out.println(t);
        }
        return recordList;
    }
}
